/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import java.io.IOException;

/**
 * <p>Project: javaweb - Upload
 * <p>Powered by webrx On 2022-03-08 15:55:36
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */

@WebServlet("/form/upload") @MultipartConfig
public class Upload extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println(req.getMethod());
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        System.out.println(req.getParameter("id"));
        System.out.println(req.getParameter("name"));

        Part part = req.getPart("file");
        System.out.println(part.getSubmittedFileName());
        System.out.println(part.getName());
        System.out.println(part.getSize());
        System.out.println(part.getContentType());

        System.out.println(req.getParameter("gender"));

        String[] loves = req.getParameterValues("love");
        for(int i=0;i<loves.length;i++) {
            System.out.println(loves[i]);
        }


        System.out.println(req.getParameter("t1"));
        System.out.println(req.getParameter("t2"));
        System.out.println(req.getParameter("t3"));

    }
}
